#!/usr/bin/python3
# -*- coding:utf-8 -*-
"""
写一个__getattr__()方法，动态返回一个属性
"""


class Student(object):

    def __init__(self, name):
        self.name = name

    def __getattr__(self, attr):
        if attr == 'age':
            return 25


def main():
    s = Student('wangnan')
    print(s.name)
    print(s.age)     # 调用没有的属性，会调用__getattr__()函数


if __name__ == "__main__":
    main()
